from haystack import indexes
from coures import models

class CourseIndex(indexes.SearchIndex, indexes.Indexable):
    text = indexes.CharField(document=True, use_template=False)
    name = indexes.CharField(model_attr='name')
    teacher=indexes.CharField(model_attr='teacher')
    intro=indexes.CharField(model_attr='intro')
    #设置模型
    def get_model(self):
        return models.CourseModel
    #设置索引字段
    def prepare_text(self, obj):
        return obj.name + obj.intro